package com.mtt.erp.common.utils;

import java.time.LocalDateTime;
import java.util.Random;

public class IdsPre {
    /**
     * 生成商品流水号前缀
     *
     * @return
     */
    public static String getMaaId() {
        //String pre = "maa";
        String monthStr = "";
        String dayStr = "";
        int year = LocalDateTime.now().getYear();
        int month = LocalDateTime.now().getMonth().getValue();
        int day = LocalDateTime.now().getDayOfMonth();
        if (month < 10) {
            monthStr = "0" + month;
        } else {
            monthStr = month + "";
        }

        if (day < 10) {
            dayStr = "0" + day;
        } else {
            dayStr = day + "";
        }

        return  year + monthStr + dayStr;
    }

    /**
     * 生成唯一标识UserCode
     *
     * @return
     */
    public static String getUserCode() {
        String str = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghigklmnopqrstuvwxyz";
        String code = new String();
        for (int i = 0; i < 4; i++) {
            char ch = str.charAt(new Random().nextInt(str.length()));
            code += ch;
        }
        return code;
    }
        public static void main (String[]args){
            System.out.println(new IdsPre().getUserCode());
        }
    }
